
op <-par(no.readonly = TRUE)
png("test_1000_480.png",width = 1000, height = 500, units = "px", pointsize = 12,bg = "white", res = NA)
par(mar=c(4,4,3,3))
fp <- read.table(file="f.txt",sep="\t",stringsAsFactors = FALSE,header = TRUE,check.names = FALSE)
readlen = 76 
ym <- ceiling( max(fp$R1_UnmRate,fp$R1_ScRate,fp$R1_InsRate,fp$R1_SnvRate,fp$R1_TotalRate))
ym2 <- ceiling(max(fp$R2_UnmRate,fp$R2_ScRate,fp$R2_InsRate,fp$R2_SnvRate,fp$R2_TotalRate))

ym3 <-max(ym,ym2)
xm <- readlen *2
plot(NA,xlab="",ylab="",xlim=c(0,xm),xaxp=c(0,xm,xm),ylim = c(0,ym3),
     yaxp=c(0,ym,ym))

x1 <- 1:readlen
x2 <- (readlen+1):xm

# 考虑一下lty和lwd的设置lty=c(1,1,1),                    # Line type  
#lwd=c(1,1,1)

points(x1,fp$R1_TotalRate,type="b",pch=20,lty=2,lwd=1,col="#6666ff")
points(x1,fp$R1_UnmRate,type = "b",pch=3,lty=2,lwd=1,col="#66ffff")
points(x1,fp$R1_ScRate,type = "b",pch=1,lty=2, lwd=1,col="#66ff66")
points(x1,fp$R1_InsRate,type="b",pch=6,lty=2,lwd=1,col="#ff66b3")
points(x1,fp$R1_SnvRate,type="b",pch=0,lty=2,lwd=1,col="#55b679")

#points(x1,fp$R1_ScRate,type = "b",pch=23,lty=2, cex=2,col="#000099", bg="#FF6666")
abline(v=readlen,col="red",lty=2,lwd=2)
par(new=T)
points(x2,fp$R2_TotalRate,type="b",pch=20,lty=2,lwd=1,col="#6666ff")
points(x2,fp$R2_UnmRate,type = "b",pch=3,lty=2,lwd=1,col="#66ffff")
points(x2,fp$R2_ScRate,type = "b",pch=1,lty=2, lwd=1,col="#66ff66")
points(x2,fp$R2_InsRate,type="b",pch=6,lty=2,lwd=1,col="#ff66b3")
points(x2,fp$R2_SnvRate,type="b",pch=0,lty=2,lwd=1,col="#55b679")

#points(x2,fp$R2_TotalRate,type="b",pch=19,col="red")
#points(x2,fp$R2_UnmRate,type = "b",pch=0,lty=2,lwd=3,col="blue")
#points(x2,fp$R1_ScRate,type = "b",pch=23,lty="dotted", cex=2,col="#000099", bg="#FF6666")
axis(4)
#mtext("Read2 Mispair Rate%",4,line=3)
title(main="Read1(left) / Read2(right) Multi-Mispair Rate(%) ")
legend(1,ym2,legend = c("TotalMispair","Unmapped","SoftClip","Insertion","Mismatch"),
       col=c("#6666ff","#66ffff","#66ff66","#ff66b3","#55b679"),lty=c(2,2,2,2,2),lwd=c(1,1,1,1,1)
       ,pch=c(20,3,1,6,0),bty = "n")

par(op)
dev.off()
#legend("topleft",legend = c("TotalMispair","Unmapped","SoftClip","Insertion","Mismatch"),
 #      col=c("#6666ff","#66ffff","#66ff66","#ff66b3","#55b679"),lty=c(2,2,2,2,2),lwd=c(1,1,1,1,1)
  #     ,pch=c(20,3,1,6,0),bty = "n")

#legend("topleft",                       # x-y coordinates for location of the legend  
#       legend=c("y1", "y2", "y3"),      # Legend labels  
#       col=c("black", "red", "blue"),   # Color of points or lines  
#       pch=c(21,19,19),                 # Point type  
#       lty=c(1,1,1),                    # Line type  
##       lwd=c(1,1,1),                    # Line width  
#       title="Time series")    




